package com.kangyi.admin.mapper;

import com.github.pagehelper.Page;
import com.kangyi.admin.annotation.AutoFill;
import com.kangyi.dto.NursingHomeBookingPageQueryDTO;
import com.kangyi.entity.NursingHomeBooking;
import com.kangyi.enumeration.OperationType;
import com.kangyi.vo.NursingHomeBookingDetailVO;
import com.kangyi.vo.NursingHomeBookingPageQueryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.stream.Stream;

/**
 * @author Blank
 * @version 1.0
 */
@Mapper
public interface NursingHomeBookingMapper {
    Page<NursingHomeBookingPageQueryVO> pageQuery(NursingHomeBookingPageQueryDTO nursingHomeBookingPageQueryDTO);

    void deleteBooking(List<Integer> ids);

    List<NursingHomeBooking> getByIds(List<Integer> ids);

    @AutoFill(value = OperationType.UPDATE)
    void updateStatus(List<NursingHomeBooking> collect);

    @Select("select * from nursing_home_booking where id = #{id};")
    NursingHomeBooking getById(Integer id);

    @Update("update nursing_home_booking set status = #{status}," +
            " reason = #{reason}, update_time = #{updateTime}, " +
            "update_user = #{updateUser} where id = #{id}")
    @AutoFill(value = OperationType.UPDATE)
    void rejectBooking(NursingHomeBooking nursingHomeBooking);

    @Select("select * from nursing_home_booking where id = #{id};")
    NursingHomeBookingDetailVO getBookingDetail(Integer id);

    @Delete("delete from nursing_home_booking where user_id = #{userId};")
    void deleteByUserId(Integer userId);

    @Delete("delete from nursing_home_booking where nursing_home_id = #{nursingHomeId};")
    void deleteByNursingHomeId(Integer nursingHomeId);
}
